package com.keensense.vcm.common.comm;

import java.util.LinkedList;
import java.util.List;

import com.keensense.vcm.common.auth.Credentials;
import com.keensense.vcm.internal.VCMConstants;

/**
 * @author lanjian
 * @date 2020/4/28 4:16 下午
 */
public class ExecutionContext {

    private String charset = VCMConstants.DEFAULT_CHARSET_NAME;

    /* Retry strategy when HTTP request fails. */
    private RetryStrategy retryStrategy;

    private Credentials credentials;

    public RetryStrategy getRetryStrategy() {
        return retryStrategy;
    }

    private List<ResponseHandler> responseHandlers = new LinkedList<ResponseHandler>();

    public void setRetryStrategy(RetryStrategy retryStrategy) {
        this.retryStrategy = retryStrategy;
    }

    public String getCharset() {
        return charset;
    }

    public void setCharset(String defaultEncoding) {
        this.charset = defaultEncoding;
    }

    public Credentials getCredentials() {
        return credentials;
    }

    public void setCredentials(Credentials credentials) {
        this.credentials = credentials;
    }

    public List<ResponseHandler> getResponseHandlers() {
        return responseHandlers;
    }

    public void addResponseHandler(ResponseHandler handler) {
        responseHandlers.add(handler);
    }

    public void insertResponseHandler(int position, ResponseHandler handler) {
        responseHandlers.add(position, handler);
    }

    public void removeResponseHandler(ResponseHandler handler) {
        responseHandlers.remove(handler);
    }
}
